package com.gexiaobao.pigeon.ui.adapter

import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.Grade
import com.gexiaobao.pigeon.databinding.ItemListMultiplePassBinding

/**
 * @Author      : hxw
 * @Date        : 2024/7/22 17:43
 * @Describe    :
 */
class AdapterListMultiplePass(data: ArrayList<Grade>) : BaseQuickAdapter<Grade, DataBindBaseViewHolder>(R.layout.item_list_multiple_pass, data) {
    override fun convert(holder: DataBindBaseViewHolder, item: Grade) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemListMultiplePassBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动


        if (holder.layoutPosition % 2 == 0) {//偶数
            holder.setBackgroundColor(R.id.llItem, ContextCompat.getColor(context, R.color.white))
        } else {
            holder.setBackgroundColor(R.id.llItem, ContextCompat.getColor(context, R.color.graye3))
        }

        if (holder.layoutPosition == data.size - 1) {
            holder.setBackgroundResource(R.id.llItem, R.drawable.round_bottom_radiu_bg12)
        }
    }
}